const { join } = require('path')

const paths = {
  root: join(__dirname, '..'),
  main: join(__dirname, '..', 'main.js'),
  dist: join(__dirname, '..', 'dist')
}

module.exports = {
  paths,

  entry: {
    main: paths.main,
  },

  output: {
    path: paths.dist,
    filename: '[name].[contenthash].js'
  },

  htmlPluginConfig: {
    title: 'antv g2 practice',
    template: './index.html'
  },

  jsLoader: {
    test: /\.js$/,
    exclude: /node_modules/,
    use: [{
      loader: 'babel-loader'
    }]
  },

  cssLoader: {
    test: /\.css$/,
    exclude: /node_modules/,
    use: ['style-loader', 'css-loader']
  },
  lessLoader: {
    test: /\.less$/,
    use: [
      'style-loader',
      'css-loader',
      {
        loader: 'less-loader',
        options: {
          javascriptEnabled: true
        }
      }
    ]
  },
  fileLoader: {
    test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|txt)(\?.*)?$/,
    use: {
      loader: 'file-loader',
      options: {
        name: 'media/[name].[hash:8].[ext]'
      }
    }
  },

  urlLoader: {
    test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
    exclude: /node_modules/,
    use: {
      loader: 'url-loader',
      options: {
        limit: 10000,
        name: 'media/[name].[hash:8].[ext]'
      }
    }
  }
}

